class CurrentEdit():
    def __init__(self):
        super(CurrentEdit, self).__init__()

    def __setting(self, spin, min, max, val=None):
        """ Setting values for all spinBoxes. """
        spin.setMinimum(min)
        spin.setMaximum(max if min <= max else min)
        spin.setValue(0 if val else min)

    def current(self, data, mode, tab, index, spins):
        """ Getting current value for editing data. """
        child = ('series', 'numbers', 'chapters')[tab]
        sub = ('look', 'change_numbers', 'future-chapters')[tab]
        ova = ('ova', 'frac') if tab == 0 else None

        now = str(data[mode][child][index]) if tab in (1, 2) else \
              f'{data[mode][child][index]}.{data[mode][ova[0]][index]}'
        track = str(data[mode][sub][index]) if tab in (1, 2) else \
              f'{data[mode][sub][index]}.{data[mode][ova[1]][index]}'

        min = now.split('.') if '.' in now else (now, 0)
        max = track.split('.') if '.' in track else (track, 0)

        vars = list(map(lambda i: int(i), list(min)+list(max)))
        values = (vars[::2], vars[1::2])

        [self.__setting(v, *values[i]) for i, v in enumerate(spins)]
        return vars

    def default(self, spin):
        """ Setting default values for spinBoxes """
        [self.__setting(i, 0, 9999999, True) for i in spin]
        return 0, 9999999, 0, 9999999

    def cleared(self, spin, values):
        """ Clearing of sub number for changed of main number. """
        vars = list(values)
        self.__setting(spin[1], 0, vars[3], True)
        if spin[0].value() == values[0]:
            self.__setting(spin[1], values[1], values[3])
